<?php


namespace app\common\model;


use think\Model;

class InviteInvestmentModel extends Model
{
    protected $name = 'invite_investment';

    /**
     * 获取列表
     * @param string $mold 类型:hb=湖北招商政策,zj=浙江招商政策
     * @return array
     */
    public function getPageList($mold, $user_id, $page, $limit): array
    {
        try {
            $where = [
                'mold' => $mold,
                'status' => 1,
            ];
            $field = 'id,mold,title,image';
            $order = [
                'weigh' => 'desc',
            ];
            $list = $this
                ->field($field)
                ->where($where)
                ->order($order)
                ->paginate($limit, false, ['page' => $page]);
            foreach ($list as $row) {
                $row->image = wdsxh_full_url($row->image);
            }
            return [
                'code' => 200,
                'msg' => '请求成功',
                'data' => $list
            ];
        }catch (\Exception $e) {
            return [
                'code' => $e->getCode(),
                'msg' => $e->getMessage(),
                'data' => []
            ];
        }
    }


    /**
     * 获取详情
     * @return array
     */
    public function getDetail($id): array
    {
        try {
            $data = $this->get($id);
            $data->image = wdsxh_full_url($data->image);
            return [
                'code' => 200,
                'msg' => '请求成功',
                'data' => $data
            ];
        }catch (\Exception $e) {
            return [
                'code' => $e->getCode(),
                'msg' => $e->getMessage(),
                'data' => []
            ];
        }
    }


}